

using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using System.Data;
using DataAccessLayer;
using InfraStructureLayer;

namespace DataLayer
{
	public class datNewsContents
	{
		public datNewsContents()
		{
		}
		
		#region  Code Factory Generated Methods
		public void DeleteNewsContentsByNewsContentId(entNewsContents parEntNewsContents, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pNewsContentId",parEntNewsContents.NewsContentId);
			parDbConnector.ExecuteNonQuery("DeleteNewsContentsByNewsContentId",insDbParamCollection);
		}
		public void InsertNewsContents(entNewsContents parEntNewsContents, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pNewsId",parEntNewsContents.NewsId);
			insDbParamCollection.Add("@pLanguageId",parEntNewsContents.LanguageId);
			insDbParamCollection.Add("@pNewsTitle",parEntNewsContents.NewsTitle);
			insDbParamCollection.Add("@pNewsBody",parEntNewsContents.NewsBody);
			insDbParamCollection.Add("@pNewsSummary",parEntNewsContents.NewsSummary);
            insDbParamCollection.Add("@pNewsBodyText", parEntNewsContents.NewsBodyText);
            insDbParamCollection.Add("@pNewsSummaryText", parEntNewsContents.NewsSummaryText);
			insDbParamCollection.AddOutput("@pNewsContentId",DbType.Int32);
			parDbConnector.ExecuteNonQuery("InsertNewsContents",insDbParamCollection);
			parEntNewsContents.NewsContentId = Convert.ToInt32(insDbParamCollection.GetOutPutParameter().Value);
		}
		public void UpdateNewsContentsByNewsContentId(entNewsContents parEntNewsContents, DbConnector parDbConnector)
		{
			DbParamCollection insDbParamCollection = new DbParamCollection();
			insDbParamCollection.Add("@pNewsContentId",parEntNewsContents.NewsContentId);
			
			insDbParamCollection.Add("@pNewsId",parEntNewsContents.NewsId);
			insDbParamCollection.Add("@pLanguageId",parEntNewsContents.LanguageId);
			insDbParamCollection.Add("@pNewsTitle",parEntNewsContents.NewsTitle);
			insDbParamCollection.Add("@pNewsBody",parEntNewsContents.NewsBody);
			insDbParamCollection.Add("@pNewsSummary",parEntNewsContents.NewsSummary);
            insDbParamCollection.Add("@pNewsBodyText", parEntNewsContents.NewsBodyText);
            insDbParamCollection.Add("@pNewsSummaryText", parEntNewsContents.NewsSummaryText);
			parDbConnector.ExecuteNonQuery("UpdateNewsContentsByNewsContentId",insDbParamCollection);
		}
       
        
		#endregion
        public DataTable SelectNewsContentsByNewsId(entNewsContents parEntNewsContents, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pNewsId", parEntNewsContents.NewsId);
            return parDbConnector.ExecuteDataTable("SelectNewsContentsByNewsId", insDbParamCollection);
        }
        public void DeleteNewsContentsByNewsId(entNewsContents parEntNewsContents, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pNewsId", parEntNewsContents.NewsId);
            parDbConnector.ExecuteNonQuery("DeleteNewsContentsByNewsId", insDbParamCollection);
        }
        public void SelectNewsContentsByNewsIdAndLanguageId(entNewsContents parEntNewsContents, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pNewsId", parEntNewsContents.NewsId);
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            DataTable insDataTable = new DataTable();
            insDataTable = parDbConnector.ExecuteDataTable("SelectNewsContentsByNewsIdAndLanguageId", insDbParamCollection);
			if (insDataTable.Rows.Count>0)
			{
				if (insDataTable.Rows[0]["NewsContentId"]!=DBNull.Value)
				{
					parEntNewsContents.NewsContentId = Convert.ToInt32(insDataTable.Rows[0]["NewsContentId"]);
				}
				if (insDataTable.Rows[0]["NewsId"]!=DBNull.Value)
				{
					parEntNewsContents.NewsId = Convert.ToInt32(insDataTable.Rows[0]["NewsId"]);
				}
				if (insDataTable.Rows[0]["LanguageId"]!=DBNull.Value)
				{
					parEntNewsContents.LanguageId = Convert.ToInt32(insDataTable.Rows[0]["LanguageId"]);
				}
				if (insDataTable.Rows[0]["NewsTitle"]!=DBNull.Value)
				{
					parEntNewsContents.NewsTitle = insDataTable.Rows[0]["NewsTitle"].ToString();
				}
				if (insDataTable.Rows[0]["NewsBody"]!=DBNull.Value)
				{
					parEntNewsContents.NewsBody = insDataTable.Rows[0]["NewsBody"].ToString();
				}
				if (insDataTable.Rows[0]["NewsSummary"]!=DBNull.Value)
				{
					parEntNewsContents.NewsSummary = insDataTable.Rows[0]["NewsSummary"].ToString();
				}
			}
        }
	}
}